
package com.bash.carrep.dao.enties;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author bash
 */
@Entity
@Table(name = "typedeclaration", catalog = "carrepdb", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TypeDeclaration.findAll", query = "SELECT t FROM TypeDeclaration t"),
    @NamedQuery(name = "TypeDeclaration.findByIdtypeDeclaration", query = "SELECT t FROM TypeDeclaration t WHERE t.idtypeDeclaration = :idtypeDeclaration"),
    @NamedQuery(name = "TypeDeclaration.findByDescriotion", query = "SELECT t FROM TypeDeclaration t WHERE t.descriotion = :descriotion")})
public class TypeDeclaration implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "idtypeDeclaration", nullable = false)
    private Integer idtypeDeclaration;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "descriotion", nullable = false, length = 45)
    private String descriotion;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idTypeDeclaration")
    private List<Declaration> declarationList;

    public TypeDeclaration() {
    }

    public TypeDeclaration(Integer idtypeDeclaration) {
        this.idtypeDeclaration = idtypeDeclaration;
    }

    public TypeDeclaration(Integer idtypeDeclaration, String descriotion) {
        this.idtypeDeclaration = idtypeDeclaration;
        this.descriotion = descriotion;
    }

    public Integer getIdtypeDeclaration() {
        return idtypeDeclaration;
    }

    public void setIdtypeDeclaration(Integer idtypeDeclaration) {
        this.idtypeDeclaration = idtypeDeclaration;
    }

    public String getDescriotion() {
        return descriotion;
    }

    public void setDescriotion(String descriotion) {
        this.descriotion = descriotion;
    }

    @XmlTransient
    public List<Declaration> getDeclarationList() {
        return declarationList;
    }

    public void setDeclarationList(List<Declaration> declarationList) {
        this.declarationList = declarationList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idtypeDeclaration != null ? idtypeDeclaration.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TypeDeclaration)) {
            return false;
        }
        TypeDeclaration other = (TypeDeclaration) object;
        if ((this.idtypeDeclaration == null && other.idtypeDeclaration != null) || (this.idtypeDeclaration != null && !this.idtypeDeclaration.equals(other.idtypeDeclaration))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.bash.carrep.dao.enties.TypeDeclaration[ idtypeDeclaration=" + idtypeDeclaration + " ]";
    }
    
}
